package com.hxexp.weixin.test.api;

import org.joda.time.LocalDateTime;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

import com.hxexp.weixin.common.exception.APIException;
import com.hxexp.weixin.hpe.api.orderpayment.OrderPaymentAPI;
import com.hxexp.weixin.hpe.api.orderpayment.model.PrepayOrderParamBean;
import com.hxexp.weixin.hpe.api.orderpayment.model.PrepayOrderResultBean;
import com.hxexp.weixin.test.runner.JUnit4WithSpringLogClassRunner;

/**
 * 订单支付接口实现类测试
 *
 * @author wang.bin
 *
 */
@RunWith(JUnit4WithSpringLogClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@ContextConfiguration(locations = { "classpath:conf/spring/spring-biz.xml", "classpath:conf/spring/spring-ehcache.xml" })
public class OrderPaymentAPIImplTester {

    @Autowired
    private OrderPaymentAPI orderPaymentAPI;

    @Test
    public void testCase01() throws APIException {

        PrepayOrderParamBean prepayOrderParamBean = new PrepayOrderParamBean();
        PrepayOrderResultBean returnValue = new PrepayOrderResultBean();
        // 设置请求参数
        prepayOrderParamBean.setOrderId("9f453861286b49c2a6ba380842690701");
        prepayOrderParamBean.setUserName("gg");
        prepayOrderParamBean.setProductId("泸州客运中心站");
        prepayOrderParamBean.setProductName("泸州客运中心站-五桂桥车站");
        prepayOrderParamBean.setProductNum("1");
        prepayOrderParamBean.setOrderAmount("106.50");
        prepayOrderParamBean.setOrderTime(LocalDateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
        prepayOrderParamBean.setTerminalType("phone");
        prepayOrderParamBean.setPayType("JSAPI");
        prepayOrderParamBean.setRemoteAddr("0:0:0:0:0:0:0:1");
        prepayOrderParamBean.setOpenId("");

        returnValue = orderPaymentAPI.prepayOrder(prepayOrderParamBean);
        System.out.println(returnValue);
    }
}
